package com.tengju.data.infrastructure.repository.clickhouse.convert;

import com.tengju.data.domain.model.clickhouse.CrmSecAnalysisM;
import com.tengju.data.domain.model.clickhouse.UserPulling;
import com.tengju.data.domain.model.user.StarLevelEnum;
import com.tengju.data.domain.model.user.UserIdCode;
import com.tengju.data.infrastructure.persistence.mybatis.dataobject.CrmSecAnalysisMDO;
import com.tengju.data.infrastructure.persistence.mybatis.dataobject.UserPullingVO;

import java.time.LocalDate;

/**
 * @author chenhang
 * @Date 2021/3/6
 */
public class CrmSecAnalysisConvert {
    public static CrmSecAnalysisM toModel(CrmSecAnalysisMDO crmSecAnalysisMDO) {
        if (crmSecAnalysisMDO == null) {
            return null;
        }
        return new CrmSecAnalysisM(
                UserIdCode.of(crmSecAnalysisMDO.getIdCode()),
                crmSecAnalysisMDO.getMMoneyOut(),
                crmSecAnalysisMDO.getTdMoneyOut(),
                crmSecAnalysisMDO.getRank(),
                crmSecAnalysisMDO.getMonth(),
                crmSecAnalysisMDO.getVisitDate()
        );
    }

    public static UserPulling toUserPullingModel(UserPullingVO userPullingVO) {
        if (userPullingVO == null) {
            return null;
        }
        return new UserPulling(
                UserIdCode.of(userPullingVO.getIdCode()),
                StarLevelEnum.parseByStarLevel(userPullingVO.getStarLevel()),
                userPullingVO.getTdCount(),
                userPullingVO.getMCount(),
                userPullingVO.getQCount(),
                userPullingVO.getAllCount()
        );
    }
}
